using Godot;
using System;

public partial class ChooseStory : MarginContainer
{
  public int CurrentStoryIndex = 0;

  public Control StoryListContainer;

  private Button _sureButton;

  public override void _Ready()
  {
    _sureButton = GetNode<Button>("MarginContainer/VBoxContainer/HBoxContainer2/Button");
    StoryListContainer = GetNode<Control>("MarginContainer/VBoxContainer/HBoxContainer/ScrollContainer/StoryListVBoxContainer");
    for (int i = 0; i < StoryListContainer.GetChildCount(); i++)
    {
      var item = StoryListContainer.GetChild<StoryItem>(i);
      item.Index = i;
      item.Root = this;
    }
    StoryListContainer.GetChild<StoryItem>(0).SetColor();

    _sureButton.Pressed += OnSureButtonClick;
  }

  private void OnSureButtonClick()
  {
    GetTree().ChangeSceneToFile("res://Sences/choose_faction.tscn");
  }
}
